home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Graphics Programming (2nd Edition)
/
Visual Basic Graphics Programming 2nd Edition.iso
/
OldSrc
/
CH1
/
SRC
/
RUBBER.FRM
< prev
next >
Wrap
Text File
|
1995-12-15
|
3KB
|
100 lines
VERSION 4.00
Begin VB.Form RubberForm
AutoRedraw = -1 'True
Caption = "Rubberband Lines"
ClientHeight = 4140
ClientLeft = 1140
ClientTop = 1800
ClientWidth = 6690
Height = 4830
Left = 1080
LinkTopic = "Form1"
ScaleHeight = 4140
ScaleWidth = 6690
Top = 1170
Width = 6810
Begin VB.Menu mnuFile
Caption = "&File"
Begin VB.Menu mnuFileExit
Caption = "E&xit"
End
End
End
Attribute VB_Name = "RubberForm"
Attribute VB_Creatable = False
Attribute VB_Exposed = False
Option Explicit
Dim Rubberbanding As Boolean
Dim OldMode As Integer
Dim FirstX As Single
Dim FirstY As Single
Dim LastX As Single
Dim LastY As Single
' ***********************************************
' Start rubberbanding.
' ***********************************************
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
' Let MouseMove know we are rubberbanding.
Rubberbanding = True
' Save DrawMode so we can restore it later.
OldMode = DrawMode
DrawMode = vbInvert
' Save the starting coordinates.
FirstX = X
FirstY = Y
' Draw the initial rubberband line.
LastX = X
LastY = Y
Line (FirstX, FirstY)-(LastX, LastY)
End Sub
' ***********************************************
' Continue rubberbanding.
' ***********************************************
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
' If we are not rubberbanding, do nothing.
If Not Rubberbanding Then Exit Sub
' Erase the previous rubberband line.
Line (FirstX, FirstY)-(LastX, LastY)
' Draw the new rubberband line.
LastX = X
LastY = Y
Line (FirstX, FirstY)-(LastX, LastY)
End Sub
' ***********************************************
' Stop rubberbanding.
' ***********************************************
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
' If we are not rubberbanding, do nothing.
If Not Rubberbanding Then Exit Sub
' We are no longer rubberbanding.
Rubberbanding = False
' Erase the previous rubberband line.
Line (FirstX, FirstY)-(LastX, LastY)
' Restore the original DrawMode.
DrawMode = OldMode
' Make the final line permanent.
Line (FirstX, FirstY)-(LastX, LastY)
End Sub
Private Sub mnuFileExit_Click()
Unload Me
End Sub